package detectCapitalUse;

public class Solution {
    public boolean detectCapitalUse(String word) {
        // 第i个单词和第i-1个单词大小写相同
        if(word.length() <= 1) return true;
        for (int i = 2; i < word.length(); i++) {
            if(check(word.charAt(i))!=check(word.charAt(i-1)))return false;
        }
        if(check(word.charAt(0)) == 1) return check(word.charAt(1))==1;
        return true;
    }
    private int check(char c) {
        if('a'<=c&&c<='z')return 1;
        return -1;
    }
}
